entry: don't force zero Y coordinate for insertion cursor
authorCosimo Cecchi <cosimoc@gnome.org>
Sat, 18 Feb 2012 18:28:21 +0000 (19:28 +0100)
committerCosimo Cecchi <cosimoc@gnome.org>
Sat, 18 Feb 2012 18:39:29 +0000 (19:39 +0100)
Subclasses of GtkEntry could set a larger height request, so we need to
apply the same calculations to the insertion cursors than we do on the
PangoLayout to render it centered under all circumstances.

gtk/gtkentry.c

index d201affe8c5fa65f7872544ec4770dc2f9225145..801dd96da5fcb992b4c03ef4f80beefb9ff44bfd 100644 (file)
@@ -5869,12 +5869,14 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
   gboolean block_at_line_end;
   PangoLayout *layout;
   const char *text;
+  gint x, y;
 
   context = gtk_widget_get_style_context (widget);
 
   layout = gtk_entry_ensure_layout (entry, TRUE);
   text = pango_layout_get_text (layout);
   cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos + priv->preedit_cursor) - text;
+  get_layout_position (entry, &x, &y);
 
   if (!priv->overwrite_mode)
     block = FALSE;
@@ -5885,19 +5887,16 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
   if (!block)
     {
       gtk_render_insertion_cursor (context, cr,
-                                   - priv->scroll_offset, 0,
+                                   x, y,
                                    layout, cursor_index, priv->resolved_dir);
     }
   else /* overwrite_mode */
     {
       GdkRGBA cursor_color;
       GdkRectangle rect;
-      gint x, y;
 
       cairo_save (cr);
 
-      get_layout_position (entry, &x, &y);
-
       rect.x = PANGO_PIXELS (cursor_rect.x) + x;
       rect.y = PANGO_PIXELS (cursor_rect.y) + y;
       rect.width = PANGO_PIXELS (cursor_rect.width);